#include <iostream>
#include <stack>
#include <string>
using namespace std;
void opera(string& str, stack<int>& st)
{
    int rightop = st.top();
    st.pop();
    int leftop = st.top();
    st.pop();
    switch (str[0])
    {
    case '+':
        st.push(leftop + rightop);
        break;
    case '-':
        st.push(leftop - rightop);
        break;
    case '*':
        st.push(leftop * rightop);
        break;
    case '/':
        st.push(leftop / rightop);
        break;
    default:
        break;
    }
}
int main() {
    int n = 0;
    while (cin >> n)
    {
        string str;
        stack<int> st;
        while (n--)
        {
            cin >> str;
            if ((str[0] == '+' || str[0] == '-' || str[0] == '*' || str[0] == '/') && str.size() == 1)
                opera(str, st);
            else
            {
                int num = stoi(str);
                st.push(num);
            }
        }
        cout << st.top() << endl;
    }
    return 0;
}